﻿// https://mp.weixin.qq.com/s?__biz=MzUxNjY5NTYxNA==&mid=2247488728&idx=2&sn=21e84293fb6c91ed9c438438ad93d7d2&scene=21#wechat_redirect
// https://leetcode-cn.com/problems/reverse-linked-list/

#include <iostream>
#include <vector>
#include <string>

using namespace std;


struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};


class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode *temp;
        ListNode *cur = head;
        ListNode *pre = nullptr;

        while (cur) {
            temp = cur->next;
            cur->next = pre;
            pre = cur;
            cur = temp;
        }
        return pre;

    }
};

int main() {
    Solution obj = Solution();
}
